home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 16 / macformat_16.iso / Recursos / GraphicConverter 2.3.1 / Plug-ins Dev.-Kit / SampleImport.p < prev   
Text File  |  1994-12-12  |  2KB  |  67 lines

  1. unit SampleImport;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Header;
  7.  
  8.     procedure Main (ImportPtr: T_ImportPtr);
  9.  
  10. implementation
  11.  
  12.     const
  13.         C_Type = 'SamI';
  14.         C_ID = $98765432;
  15.  
  16.     type
  17.         T_LongArr = array[0..10000] of Longint;
  18.         T_LongPtr = ^T_LongArr;
  19.  
  20.     procedure Main (ImportPtr: T_ImportPtr);
  21.  
  22.         var
  23.             longPtr: T_LongPtr;
  24.             ok: Boolean;
  25.  
  26.     begin
  27.     ok := False;
  28.  
  29. { Analyze the Data in ImportPtr^.dataHdl, the handle is locked !!! }
  30.  
  31.     longPtr := T_LongPtr(ImportPtr^.srcDataHdl^);
  32.  
  33.     if (longPtr^[0] = C_ID) then
  34.         begin
  35.     { Set all dest values if this function can import the data. }
  36.         ImportPtr^.destBitsPerPixel := longPtr^[1];
  37.         ImportPtr^.destBytesPerLine := longPtr^[2];
  38.         ImportPtr^.destWidth := longPtr^[3];
  39.         ImportPtr^.destHeight := longPtr^[4];
  40.         ImportPtr^.destDataSize := longPtr^[5];
  41.         ImportPtr^.destKindStr := 'Sample File Format';
  42.         ImportPtr^.destFileType := C_Type;
  43.  
  44.         BlockMove(ptr(ord4(longPtr) + 6 * 4), ptr(ImportPtr^.destColorTablePtr), 256 * 3 * 2);
  45.  
  46.     { Allocate the destDataHdl }
  47.         ImportPtr^.destDataHdl := NewHandle(ImportPtr^.destDataSize);
  48.         if MemError = noErr then
  49.             begin
  50.             HLock(ImportPtr^.destDataHdl);
  51.             BlockMove(ptr(ord4(longPtr) + 6 * 4 + 256 * 3 * 2), ImportPtr^.destDataHdl^, ImportPtr^.destDataSize);
  52.             HUnlock(ImportPtr^.destDataHdl);
  53.             ok := True;
  54.             end;
  55.  
  56.         end;
  57.  
  58. { Additional: }
  59. { Generate a PICT if the createVectorPict field is true and your function imports }
  60. { vector data (you have to allocate the vectorPictHdl with OpenPicture in this case). }
  61.  
  62. { Set the success value to 1 if everything was ok }
  63.     if ok then
  64.         ImportPtr^.success := 1;
  65.     end;
  66.  
  67. end.